<?php
class Admin_notify extends Admin_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->model('admin_notify/notify_model','notify');
	}
	
	function index(){
		$data['notify'] = $this->notify->get();
		$this->template->build('index',$data);
	}
	
	function form($id=false){
		$data['notify'] = $this->notify->get_row($id);
		$data['pagination'] = $this->notify->pagination();
		$this->template->build('form',$data);
	}
	
	function save(){
		if($_POST){
			$_POST['create_date'] = date("Y-m-d H:i:s");
			$_POST['user_id'] = $this->session->userdata('id');
			if($_FILES['image']['name'])
			{
				$_POST['image'] = $this->notify->upload($_FILES['image'],'uploads/notify/');
			}
			$this->notify->save($_POST);
			set_notify('success', lang('save_data_complete'));
		}
		redirect('admin_notify/index');
	}
	
	function delete($id=false){
		if($id){
			$this->notify->delete($id);
			set_notify('success', lang('delete_data_complete'));
		}
		redirect('admin_notify/index');
	}
}
?>